home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Internet Info 1994 March
/
Internet Info CD-ROM (Walnut Creek) (March 1994).iso
/
networking
/
ip
/
ka9q
/
src.arc
/
ICMPDUMP.C
< prev
next >
Wrap
C/C++ Source or Header
|
1989-08-11
|
1KB
|
65 lines
#include <stdio.h>
#include "global.h"
#include "mbuf.h"
#include "internet.h"
#include "icmp.h"
#include "trace.h"
#include "ip.h"
/* Dump an ICMP header */
void
icmp_dump(bpp,source,dest,check)
struct mbuf **bpp;
int32 source,dest;
int check; /* If 0, bypass checksum verify */
{
struct icmp icmp;
int16 csum;
if(bpp == NULLBUFP || *bpp == NULLBUF)
return;
csum = cksum(NULLHEADER,*bpp,len_mbuf(*bpp));
ntohicmp(&icmp,bpp);
printf("ICMP: type %s",smsg(Icmptypes,ICMP_TYPES,uchar(icmp.type)));
switch(uchar(icmp.type)){
case DEST_UNREACH:
printf(" code %s",smsg(Unreach,NUNREACH,uchar(icmp.code)));
break;
case REDIRECT:
printf(" code %s",smsg(Redirect,NREDIRECT,uchar(icmp.code)));
break;
case TIME_EXCEED:
printf(" code %s",smsg(Exceed,NEXCEED,uchar(icmp.code)));
break;
case PARAM_PROB:
printf(" pointer %u",icmp.args.pointer);
break;
case ECHO:
case ECHO_REPLY:
case INFO_RQST:
case INFO_REPLY:
case TIMESTAMP:
case TIME_REPLY:
printf(" id %u seq %u",icmp.args.echo.id,icmp.args.echo.seq);
break;
}
if(check && csum != 0){
printf(" CHECKSUM ERROR (%u)",csum);
}
printf("\n");
/* Dump the offending IP header, if any */
switch(icmp.type){
case DEST_UNREACH:
case TIME_EXCEED:
case PARAM_PROB:
case QUENCH:
case REDIRECT:
printf("Returned ");
ip_dump(bpp,0);
}
}